package com.zhy.http.library.callback;

import ohos.media.image.ImageSource;
import ohos.media.image.PixelMap;
import ohos.media.image.common.PixelFormat;
import okhttp3.Response;

/**
 * Created by zhy on 15/12/14.
 *
 * @deprecated use {@link InputStreamCallback}
 */
@Deprecated
public abstract class BitmapCallback extends Callback<PixelMap> {
    @Override
    public PixelMap parseNetworkResponse(Response response, int id) throws Exception {
        ImageSource.SourceOptions opts = new ImageSource.SourceOptions();
        opts.formatHint = "image/png";
        ImageSource imageSource = ImageSource.create(response.body().byteStream(), opts);
        ImageSource.DecodingOptions decodingOpts = new ImageSource.DecodingOptions();

        decodingOpts.desiredPixelFormat = PixelFormat.ARGB_8888;
        return imageSource.createPixelmap(decodingOpts);
    }
}
